﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="UserProfile.aspx.cs" 
         Inherits="UserProfile" Title="&#1040;&#1090;&#1072;&#1084;&#1072;&#1085; &#1084;&#1077;&#1073;&#1077;&#1083;&#1100;: &#1051;&#1080;&#1095;&#1085;&#1099;&#1081; &#1082;&#1072;&#1073;&#1080;&#1085;&#1077;&#1090;" %>
<script runat="server">
    public void EditUserProf(object sender, EventArgs e)
    {

        // Create an empty Profile for the newly created user
        //ProfileCommon p = (ProfileCommon)ProfileCommon.Properties.Remove(logName.ToString());
        ProfileCommon pr = (ProfileCommon)ProfileCommon.Create(logName.ToString(), true);

        // Populate some Profile properties off of the create user wizard
        if (Name1.Text != "") pr.Name = Name1.Text;
        if (Surname1.Text != "") pr.Surname = Surname1.Text;
        if (LastName1.Text != "") pr.LastName = LastName1.Text;
        if (Phone1.Text != "") pr.Phone = Phone1.Text;

        pr.Save();
       // p.Save();
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="pagetitle">&#1051;&#1080;&#1095;&#1085;&#1099;&#1081; &#1082;&#1072;&#1073;&#1080;&#1085;&#1077;&#1090;</div>
        <div class="userProfile">
        <div class="clear">
            <div class ="personalInfo">
                <h1>Персональная информация</h1>
                <div class="logName">
                    <asp:Label ID="lbllogName" AssociatedControlID="logName" Text="Учётная запись:" runat="server" />
                    <asp:LoginName ID="logName" runat="server" />
                </div>
                <div class="userRole">
                    <asp:Label ID="lblRole" AssociatedControlID="grdRoles" Text="Роль:" runat="server" />
                    <asp:GridView id="grdRoles" DataSourceID="srcRoles" ShowHeader="false" EmptyDataText="user" GridLines="None" Runat="server" CssClass="roleName" />
                    <asp:ObjectDataSource id="srcRoles" TypeName="System.Web.Security.Roles" SelectMethod="GetRolesForUser" Runat="server" />
                </div>
                <div class="userName">    
                    Имя: <asp:Label  ID="Name" runat="server" Text="" />
                </div>
                <div class="userSurname">
                    Фамилия: <asp:Label  ID="Surname" runat="server" Text="" />
                </div>
                <div class="userLastName">
                    Отчество: <asp:Label  ID="LastName" runat="server" Text="" />
                </div>
                <div class="userPhone">
                    Телефон: <asp:Label  ID="Phone" runat="server" Text="" />            
                </div>
            </div>
            <div class="userForm">
                <asp:ChangePassword ID="ChangePassword1" runat="server" CssClass="userForm">
                    <ChangePasswordTemplate>
                        <h1>&#1048;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1077; &#1087;&#1072;&#1088;&#1086;&#1083;&#1103;</h1>
                        <div class="currentPass">
                            <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword" Text="&#1055;&#1072;&#1088;&#1086;&#1083;&#1100;:" CssClass="label" />
                            <asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" CssClass="form" />
                            <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" 
                            ErrorMessage="&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1087;&#1072;&#1088;&#1086;&#1083;&#1100;."  ToolTip="&#1042;&#1074;&#1077;&#1076;&#1080;&#1090;&#1077; &#1087;&#1072;&#1088;&#1086;&#1083;&#1100;." ValidationGroup="ChangePassword1">*
                            </asp:RequiredFieldValidator>
                        </div>
                        <div class="newPass">
                            <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword" Text="&#1053;&#1086;&#1074;&#1099;&#1081; &#1087;&#1072;&#1088;&#1086;&#1083;&#1100;:" CssClass="label" />
                            <asp:TextBox ID="NewPassword" runat="server" TextMode="Password" CssClass="form" />
                            <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" 
                            ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangePassword1">*
                            </asp:RequiredFieldValidator>
                        </div>
                        <div class="confirmPas">
                            <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword" Text="&#1055;&#1086;&#1076;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1077; &#1085;&#1086;&#1074;&#1086;&#1075;&#1086; &#1087;&#1072;&#1088;&#1086;&#1083;&#1103;:" CssClass="label" />
                            <asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password" CssClass="form" />
                            <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" 
                            ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangePassword1">*
                            </asp:RequiredFieldValidator>
                        </div>
                        <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" 
                        ControlToValidate="ConfirmNewPassword" Display="Dynamic" ErrorMessage="&#1055;&#1086;&#1076;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1077; &#1080; &#1085;&#1086;&#1074;&#1099;&#1081; &#1087;&#1072;&#1088;&#1086;&#1083;&#1100; &#1086;&#1083;&#1078;&#1085;&#1099; &#1089;&#1086;&#1074;&#1087;&#1072;&#1076;&#1072;&#1090;&#1100;."
                        ValidationGroup="ChangePassword1"></asp:CompareValidator>
                        <asp:Literal ID="FailureText" runat="server" EnableViewState="False" />
                        <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="&#1048;&#1079;&#1084;&#1077;&#1085;&#1080;&#1090;&#1100; &#1087;&#1072;&#1088;&#1086;&#1083;&#1100;" 
                        ValidationGroup="ChangePassword1" CssClass="changePassButton"  />
                        <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="&#1054;&#1090;&#1084;&#1077;&#1085;&#1072;" CssClass="cancelButton"  />
                    </ChangePasswordTemplate>
                    <SuccessTemplate>
                        &#1057;&#1084;&#1077;&#1085;&#1072; &#1087;&#1072;&#1088;&#1086;&#1083;&#1103; &#1079;&#1072;&#1074;&#1077;&#1088;&#1096;&#1077;&#1085;&#1072;.
                        &#1055;&#1072;&#1088;&#1086;&#1083;&#1100; &#1080;&#1079;&#1084;&#1077;&#1085;&#1105;&#1085; &#1091;&#1089;&#1087;&#1077;&#1096;&#1085;&#1086;!
                        <asp:Button ID="ContinuePushButton" runat="server" CausesValidation="False" CommandName="Continue" Text="&#1053;&#1072; &#1075;&#1083;&#1072;&#1074;&#1085;&#1091;&#1102;"  PostBackUrl="~/Default.aspx"/>
                    </SuccessTemplate>
                </asp:ChangePassword>
            </div>
            <div class="userDetails">
                <h1>Изменение личных даных</h1>
                <div class="nameForm">
                    <asp:Label ID="NameLabel" runat="server" AssociatedControlID="Name1" Text="Имя:" CssClass="label" />
                    <asp:TextBox ID="Name1" runat="server" CssClass="form" />
                </div>
                <div class="surnameForm">
                    <asp:Label ID="SurnameLabel" runat="server" AssociatedControlID="Surname1" CssClass="label" Text="Фамилия:" />
                    <asp:TextBox ID="Surname1" runat="server" CssClass="form" />
                </div>
                <div class="lastNameForm"> 
                    <asp:Label ID="LastNameLabel" runat="server" AssociatedControlID="LastName1" Text="Отчество:" CssClass="label" />
                    <asp:TextBox ID="LastName1" runat="server" CssClass="form" />
                </div>
                <div class="phoneForm">                 
                    <asp:Label ID="PhoneLabel" runat="server" AssociatedControlID="Phone1" Text="Телефон:" CssClass="label" />
                    <asp:TextBox ID="Phone1" runat="server" CssClass="form" />
                </div>
                <asp:Button runat="server" ID="btnConfirm" OnClick="EditUserProf" Text="Обновить" PostBackUrl="~/Default.aspx" />
            </div>
        </div>
    </div>
</asp:Content>
